/*
 * @Author: 黄达全
 * @Date: 2024-08-07 11:55:00
 * @LastEditTime: 2024-08-07 16:04:26
 */
import axios from "../index"
import type { NoticeApi, ApiResponse, NoticePageVO } from "@/common/type"


export default {
    //新增公告
    async add(form) {
        return (await axios.post("/admin/notice", form)).data as ApiResponse<null>
    },
    //分页获取公告列表
    async page(page, pageSize) {
        return (await axios.get(`/admin/notice/${page}`, {
            params: {
                pageSize
            }
        })).data as ApiResponse<NoticePageVO>
    },
    // 删除公告、批量删除
    async delete(ids) {
        const queryString = ids.map(id => `ids=${id}`).join('&');  
        return (await axios.delete(`/admin/notice?${queryString}`)).data as ApiResponse<null>
    },
    //更新公告
    async update(form) {
        return (await axios.put("/admin/notice", form)).data as ApiResponse<null>
    }

} as NoticeApi